<template>
  <div class="da-detail-wrapper">
    <basic-container>
      <div class="form-designer">
          <view-form v-if="modal && showView"
          :driverList="driverList"
              :option="option1"
              :dataobj="dataobj"
          ></view-form>
          <render-form v-if="modal && !showView"
          :driverList="driverList"
              :option="option1"
              :formObj="dataobj"
              :isReturn="true"
          ></render-form>
      </div>
    </basic-container>
  </div>
</template>

<script type="text/ecmascript-6">
import ViewForm from '@/components/table-design/viewRender'
import RenderForm from '@/components/table-design/newRender'
import {driverList} from '@/api/car/cardriver'
import {billDetail} from '@/api/bill'
export default {
  components: { ViewForm, RenderForm },
  data () {
    return {
      driverList: [],
      dataobj: {},
      showView: true,
      option1: {},
      modal:false
    }
  },
  mounted() {
    let params = this.$route.params
    driverList().then(response => {
        this.driverList = response.data.data
    })
    this.viewNodeForm(params.id, params.taskId)
  },
  methods: {
    viewNodeForm(id, taskId) {
        let self = this
        billDetail(id, taskId).then(response => {
            let formInfo = JSON.parse(response.data.data.formInfo)
            self.dataobj = response.data.data
            if ((response.data.data.showSelectType && response.data.data.showSelectType.indexOf('ROLE_DEPT_LEADER') !== -1 || response.data.data.taskName==='发起人')) {
              if(response.data.data.canTodo){
                self.showView = false
              }
            }
            // if ((response.data.data.showSelectType && response.data.data.showSelectType.indexOf('ROLE_DEPT_LEADER') !== -1 || response.data.data.canTodo)) {
            //   self.showView = false
            // }
            self.option1 = formInfo
            self.modal = true
        })
    }
  }
}
</script>

<style lang="scss">
.da-detail-wrapper{
  padding-bottom:0;
  #pane-0{
    // width: 1240px;
  }
  .form-designer, .view-wrapper .el-tabs{
    height:calc(100vh - 140px);
    .el-tab-pane{
      height:calc(100vh - 140px);
      overflow: auto;
    }
    .render-form{
      min-height: calc(100vh - 400px);
      // height: calc(100vh - 400px) !important;
    }
  }
}
</style>
